package day16_Runnable.demo09例子;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;

public class Demo01_ClazzSum {
    public static void main(String[] args) throws Exception{
        long start = System.currentTimeMillis();//获取当前系统的时间
        HashMap<String, Integer> map = new HashMap<>();
        BufferedReader br = new BufferedReader(
                new FileReader("E:\\csw\\Demo\\a\\bigdata.txt"));
        String line;
        while ((line=br.readLine())!=null){//循环读取数据
            String clazz = line.split(",")[4];//切分字段获取班级
            if(map.containsKey(clazz)){//判断是否在map中
                map.put(clazz,map.get(clazz)+1);
            }else {
                map.put(clazz,1);
            }
        }
        br.close();
        System.out.println(map);
        long end = System.currentTimeMillis();//获取当前系统的时间
        System.out.println(end-start);//2575
    }
}
